#ifndef __DECODER_H__
#define __DECODER_H__

#include "main.h"

#define LED HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET)
#define LED_NONE HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET)

#define DECODER_MAX_LENGTH 66

struct Decoder {
  uint16_t period[DECODER_MAX_LENGTH];
  uint16_t length;

  uint16_t period_buffer[DECODER_MAX_LENGTH];
  uint16_t length_buffer;

  uint16_t cnt;
  uint16_t lead;
  uint32_t data;

  char info[64];
};

extern struct Decoder decoder;

void decoder_init(void);

#endif
